Day 2 - Data Type & Calculate


Posted by pei_______ on 2022-04-13

learning from 100 Days of Code: The Complete Python Pro Bootcamp for 2022


Data Type : int( ) / float( ) / str( )

Type Checking : type( )

Type Error : input( ) = string 、 f string = print(f"{ }")

Calculate / round( 1.666666 , 2) = 1.67

# BMI Calculator
height = input("enter your height in m: ")
weight = input("enter your weight in kg: ")

w = int(weight)
h = float(height)
print(int(w/h**2))

# Life in Weeks
age = input("What is your current age?")

x =(90- int(age))*365
y =(90- int(age))*52
z = (90- int(age))*12

print(f"You have {x} days, {y} weeks, and {z} months left.")

# tip-calculator
print("Welcome to the tip calculator!")
pay = float(input("What was the total bill? $"))
tip = int(input("How much tip would you like to give? 10, 12, or 15? "))
person = int(input("How many people to split the bill?"))

bill = pay * ((tip/100)+1) / person
bill_final = round(bill, 2)

print(f"Each person should pay: $ {bill_final}")

#Python #課堂筆記 #100 Days of Code







Related Posts

[ week 7 ] 前端必備 JavaScript

[ week 7 ] 前端必備 JavaScript

[FE101] HTML 基礎

[FE101] HTML 基礎

從使用者的角度來看,什麼是 API ?

從使用者的角度來看,什麼是 API ?


Comments